package com.example.toutiao.ui.main.presenter

import com.example.toutiao.http.HttpUtils
import com.example.toutiao.http.ResponseListener
import com.example.toutiao.http.UserApi
import com.example.toutiao.mvp.model.BaseModel
import com.example.toutiao.mvp.presenter.BasePresenter
import com.example.toutiao.ui.main.model.CodeModel
import com.example.toutiao.ui.main.view.RegisterView
import com.example.toutiao.ui.main.view.SendCodeView

class SendCodePresenter: BasePresenter<SendCodeView>() {
    fun getCode(phoneNumber:String){
        HttpUtils.sendHttp(HttpUtils.createApi(UserApi::class.java).getCode(phoneNumber),object :
            ResponseListener<BaseModel<CodeModel>> {
            override fun onSuccess(data: BaseModel<CodeModel>) {
                if(data!=null){
                    getBaseView()!!.setData(data.data)
                }
            }

            override fun onFail(err: String) {
                getBaseView()!!.setError(err)
            }

        })
    }
}